<template>
    <div class="mine">
    
        <div class="first" style="background-color: white;border-radius: 20px;" v-if="Object.keys(data).length > 0">
            <div class="" style="display: flex;align-items: center;justify-content: space-around;padding: 10px;">
                <div class="left">
                    <img :src="tou" class="avatar">
                </div>

                <div class="middle">
                    <div class="right_first_line">
                        <!-- 名称 -->
                        <div class="name">
                            {{ data.data.name }}
                        </div>
                        <div class="xiaozi">感谢关注爱脑行动</div>
                    </div>
                </div>
            </div>

            <div class="right">
                <el-button type="primary" round @click="clear">退出登录</el-button>
            </div>
        </div>
        <div class="first" style="background-color: white;border-radius: 20px;" v-else>
            <div class="" style="display: flex;align-items: center;justify-content: space-around;padding: 10px;">
                <div class="left">
                    <img :src="tou" class="avatar">
                </div>

                <div class="middle">
                    <div class="right_first_line">
                        <div class="xiaozi" style="font-size: 13px;">期待与您一起关注脑健康</div>
                    </div>
                </div>
            </div>

            <div class="right">
                <el-button type="primary" round @click="clear">退出登录</el-button>
            </div>
        </div>

        <div class="cha" @click="next">
            <img src="https://www.ainaoxingdong.com/api/an-media/images/an/static/personal/ScreeningResult.png" alt="">
        </div>
    </div>
</template>

<script>
import axios from "axios";
import {
    getUrl
} from "@/config.js";

export default {

    data() {
        return {
            data: {
                sex: ''
            },
        }
    },

    computed: {

        tou() {
            // let sex = localStorage.getItem('sex')
            // console.log(sex)
            var sexInfo = "";
            if (this.$route.query.sex == 1) {
                sexInfo = "https://www.ainaoxingdong.com/api/an-media/images/an/static/personal/boy.jpg"
            }
            if (this.$route.query.sex == 0) {
                sexInfo = "https://www.ainaoxingdong.com/api/an-media/images/an/static/personal/girl.jpg"
            }
            if (this.$route.query.sex == null) {
                sexInfo = "https://www.ainaoxingdong.com/api/an-media/images/an/static/personal/head.png"
            }
            return sexInfo;
            // return 'sex = 1' ? "https://www.ainaoxingdong.com/api/an-media/images/an/static/personal/girl.jpg" :
            // 	"https://www.ainaoxingdong.com/api/an-media/images/an/static/personal/boy.jpg";
            // return "https://www.ainaoxingdong.com/api/an-media/images/an/static/personal/girl.jpg"
        },
    },
    methods: {
        report(params = {}) {
            // getReport(params).then(res => {
            // 	const {
            // 		data
            // 	} = res
            // 	this.data = data.data || {}
            // 	console.log('data,', data)
            // })

            var baseUrl = getUrl();
            var token = localStorage.getItem("token");
            axios.get(
                baseUrl + "/an/wechat_app/wechat_user/report?token=" + token,
                {
                    js_patientId: params.js_patientId,
                    js_token: params.js_token
                }
            ).then((res) => {
                const {
                    data
                } = res
                this.data = data.data || {}
                console.log('data,', data)
            });
        },

        clear() {
            window.localStorage.clear();
            this.$router.push("/login");
        },
        next() {
            this.$router.push({
                path: '/result',
                query: {
                    sex: this.$route.query.sex
                }

            })
        },

    },
    mounted() {
        this.report();
    }
}
</script>

<style lang="scss" scoped>
.mine {
    height: 100%;
    background-color: #F9F9F9;
}

.first {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 184px;
    background-color: #F9F9F9;

    .left {
        width: 80px;
        height: 80px;
        border-radius: 50%;
        border: 2px solid #E7EFFF;

        img {
            width: 100%;
            height: 100%;
            border-radius: 50%;
        }
    }

    .middle {
        margin-left: 24px;

        .right_first_line {
            // display: flex;
            // width: 100%;
            // justify-content: space-between;

            .name {
                height: 30px;
                font-size: 22px;
                font-family: PingFangSC-Medium, PingFang SC;
                font-weight: 900;
                // color: #003941;
                color: rgba(85, 153, 255, 1);
                // line-height: 48px;
            }

            .education {
                line-height: 48px;
            }
        }
    }

    .right {
        // flex: 1;
        padding-right: 10px;
        display: flex;
        justify-content: space-between;


        .right_two_line {
            display: flex;
            flex-direction: column;
            width: 100%;
            align-items: flex-end;
            justify-content: space-between;

            .top {
                width: 150px;
                display: flex;
                align-items: center;
                justify-content: space-between;
            }
        }
    }
}

.xiaozi {
    font-size: 16px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    // color: #336c74;
    color: #B5C3E0;
}

// .left {
//     width: 122px;
//     height: 122px;
//     border-radius: 50%;
//     border: 2px solid #E7EFFF;

//     img {
//         width: 100%;
//         height: 100%;
//         border-radius: 50%;
//     }
// }

// .middle {
//     margin-left: 34px;




//         .name {
//             height: 48px;
//             font-size: 32px;
//             font-family: PingFangSC-Medium, PingFang SC;
//             font-weight: 900;
//             // color: #003941;
//             color: rgba(85, 153, 255, 1);
//             // line-height: 48px;
//         }

//         .education {
//             line-height: 48px;
//         }
// }

.cha {
    width: 287px;
    height: 79px;
    display: block;
    border-radius: 40px;
    box-shadow: 4px 6px 18px 0px rgba(30, 90, 102, 0.1);
    margin: 200px auto;
}

.cha img {
    width: 100%;
    height: 100%;
}</style>